#include<bits/stdc++.h>
using namespace std;
class Solution {
	public:    vector<int> searchRange(vector<int>& nums, int target) {
		int n=nums.size();
		if(n==0) return {-1,-1};
		int l=0,r=n-1;
		while(l<r)
		{
			int mid=l+(r-l)/2;
			if(nums[mid]<target)
			{
				l=mid+1;
			}
			else r=mid;
		}
		vector<int> ans;
		
		ans.push_back(l);
		if(nums[l]!=target)return {-1,-1};
		l=0,r=n-1;
		while(l<r)
		{
			int mid=l+(r-l+1)/2;
			if(nums[mid]>target)
			{
				r=mid-1;
			}
			else l=mid;
		}
		if(nums[r]!=target)return {-1,-1};
		ans.push_back(r);
		return ans;
	}
};
